define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'form4.childen/index',
        add_url: 'form4.childen/add',
        edit_url: 'form4.childen/edit',
        delete_url: 'form4.childen/delete',
        export_url: 'form4.childen/export',
        modify_url: 'form4.childen/modify',
		temperature_url: 'form4.childen/temperature_index',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh','add','delete'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'ID', width: 80},
                    {field: 'name', title: '姓名'},
                    {field: 'form4.name', title: '密接上级'},
                    {field: 'sex', search: 'select', selectList: ["男","女"], title: '性别'},
                    {field: 'id_card', title: '身份证号'},
                    {field: 'living', title: '现居住地址'},
                    {field: 'mobile', title: '手机号'},
                    {field: 'desc', title: '备注', search: false},
                    {field: 'create_time', title: '创建时间', search: 'range'},
                    {width: 180, title: '操作', templet: ea.table.tool},

                ]],
            });

            ea.listen();
        },
		temperature_index: function () {
            ea.table.render({
                init: {
                    table_elem: '#currentTable',
                    table_render_id: 'currentTableRenderId',
                    index_url: 'form4.childen/temperature_index?id=' + source_id,
                },
                toolbar: ['refresh'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'ID', width: 100},
                    {field: 'form4_childen.name', title: '姓名'},
                    {field: 'id_card', title: '身份证号'},
					{field: 'form4_childen.mobile', title: '手机号'},
                    {field: 'temperature', title: '体温（℃）', templet: function (d) {
                            if (d.temperature > 37.3) {
                                return '<div class="layui-table-cell" style="background-color: red;color: #fff;">' + d.temperature + '</div>';
                            }
                            return '<div class="layui-table-cell">' + d.temperature + '</div>';
                        }},
                    {field: 'create_time', title: '上报时间', search: 'range'},
                ]],
            });

            ea.listen();
        },
		temperature_add: function () {
            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});